<template>
  <div class="commentitems">
    <div class="commentItem" v-for="(item, index) in commentchild" :key="index">
      <div class="user_img">
        <img
          :src="item.userinfo.user_img"
          alt=""
          v-if="item.userinfo && item.userinfo.user_img"
        />
        <img src="@/assets/default.jpeg" alt="" v-else />
        <p>
          <span v-if="item.userinfo">{{ item.userinfo.name }}</span>
          <span v-else>无名</span>
          <span>{{ item.comment_date }}</span>
        </p>
      </div>
        <div class="commentContent">
          <div style="margin:2.778vw 0"  v-if="!temp">
            {{ item.comment_content }}
            <span class="publish" @click="publishClick(item.comment_id)">回复</span>
          </div>
          <div style="margin:2.778vw 1.389vw"  v-else>
            回复 <span style="color:#00b8ff">{{item.parent_user_info.name}}</span> :{{ item.comment_content }}
            
            <span class="publish" @click="publishClick(item.comment_id)">回复</span>
          </div>
        </div>
        <commentnexttitle :commentchild="item.child" @postChild="postChild" :temp="true"></commentnexttitle>
    </div>
  </div>
</template>
<script>
export default {
  name: "commentnexttitle",
  props: ["commentchild","temp"],
  data(){
    return{
      
    }
  },
  methods: {
    publishClick(id){
      this.$emit('postChild',id)
      this.$emit('PostPublish',id)
    },
    postChild(id){
      this.publishClick(id)
      this.$emit('PostPublish',id)
    }
  },
};
</script>
<style lang="scss">
.commentitems {
  .commentItem {
    .commentContent{
      position: relative;
      margin-top: 10px;
      .publish{
        position: absolute;
        right:4.167vw;
        color:red;

      }
    }
    display: flex;
    flex-direction: column;
    .user_img {
      display: flex;
      img{
        margin: 0 1.389vw;
        border-radius: 50%;
      }
      p {
        flex: 1;
        font-size: 3.611vw;
        color: #555;
        display: flex;
        justify-content: space-between;
        margin-bottom: 1.389vw;
      }
    }
  }
}
</style>